import unittest
import readConfig as readConfig
from common import Log as Log
from common import configHttp as ConfigHttp
from interface.company.LoginForWebCompany import LoginForWebCompany
from interface.job.PublishJob import PublishJob
from common import globalvar as gl
from common import getTime as time #获取时间戳
localReadConfig = readConfig.ReadConfig()
configHttp = ConfigHttp.ConfigHttp()
info = {}


class TestForLogin(unittest.TestCase):
    case_name = "chenchi_casename"


    def description(self):
        """
        test report description
        :return:
        """
        #self.case_name

    def setUp(self):
        """

        :return:
        """
        self.log = Log.MyLog.get_log()
        self.logger = self.log.get_logger()
        print(self.case_name+"测试开始前准备")

    def testLogin(self):
        """
        step1 用户登录，获取token
        :return:
        """
        r = LoginForWebCompany(mobile="12222222222", password="q123456").do_login()
        self.assertEqual(r.status_code, 200)
        user_token = r.json()["data"]["token"]
        print("正文中token:"+r.json()["data"]["token"])
        print("token:"+str(user_token))


        """
        step2 发布兼职
        :return:
        """
        job =PublishJob(token=str(user_token),classificationId="10176", title="ccjob"+str(time.nowTime()),jobCount="3",jobDesc="123123123",deadline="2019-01-13 00:00:00",salaryUnit="2",salaryTimeUnit="4",bonus="1",areaId="0",addressBuilding="不限工作地点",contactNo="16823452345",heightRequire="1").do_publish_job()
        self.assertEqual(job.status_code, 200)
        print("job:"+str(job.json()))
        print("code:" + str(job.json()["code"]))
        logger = gl.get_value('logger')
        logger.info("执行:"+"PublishJob")


        #xxx




    def tearDown(self):
        """


        print("测试结束，输出log完结\n\n")

    # def checkResult(self):
    #     """
    #     check test result
    #     :return:
    #     """
    #     self.info = self.return_json.json()
    #     # show return message
    #     common.show_return_msg(self.return_json)
    #
    #     if self.result == '0':
    #         email = common.get_value_from_return_json(self.info, 'member', 'email')
    #         self.assertEqual(self.info['code'], self.code)
    #         self.assertEqual(self.info['msg'], self.msg)
    #         self.assertEqual(email, self.email)
    #
    #     if self.result == '1':
    #         self.assertEqual(self.info['code'], self.code)
    #         self.assertEqual(self.info['msg'], self.msg)
if __name__ == '__main__':
    TestForLogin.testLogin()
